package com.wryyyyy.service.impl;

import com.wryyyyy.utils.ExcelService;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

import static com.wryyyyy.utils.SystemConstants.ARGS_LENGTH;

@Component
public class ArgumentsHandle {
    @Resource
    private ExcelService excelService;

    private List<Map<Integer, Object>> list;

    public List<Map<Integer, Object>> getList() {
        return list;
    }

    public String[] getArgs(String filePath) {
        excelService.readExcelFile(filePath);
        list = excelService.getArguments();

        // 准备给c++用的参数
        String[] ans = new String[ARGS_LENGTH];
        int i = 0;
        for (Map<Integer, Object> map : list) {
            for (Integer mapI : map.keySet()) {
                ans[i] = (String) map.get(mapI);
                i++;
            }
        }

        return ans;
    }
}